package com.ruoyi.web.controller.material;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.service.IBdMaterialService;
import com.ruoyi.system.service.IBdProjectclassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "物资接口")
@RestController
@RequestMapping("/material")
public class MaterialController extends BaseController {

    @Autowired
    private IBdMaterialService iBdMaterialService;
    @Autowired
    private IBdProjectclassService iBdProjectclassService;
    @ApiOperation("查看物资列表")
    @PostMapping("/getMaterialList")
    public TableDataInfo getMaterialList(RequestParam requestParam) {
        startPage();
        List<MarterialVo> list =  iBdMaterialService.getMaterialList(requestParam);
        return getDataTable(list);
    }

    @ApiOperation("分类物资查询")
    @PostMapping("/sort")
    public AjaxResult sortMaterial() {
        List<SortVo> list =  iBdMaterialService.sortMaterial();
        return AjaxResult.success(list);
    }

    @ApiOperation("根据分类ID查询分类名称")
    @PostMapping("/sortById")
    public AjaxResult sortMaterial(String id) {
        SortVo sortVo =  iBdMaterialService.sortById(id);
        return AjaxResult.success(sortVo);
    }

    @ApiOperation("获取项目")
    @PostMapping("/getProject")
    public AjaxResult getProject() {
        List<ProjectVo> list =  iBdProjectclassService.getProject();
        return AjaxResult.success(list);
    }

    @ApiOperation("供货商")
    @PostMapping("/getAllSuppiler")
    public AjaxResult getAllSuppiler() {
        List<SupplierVo> supplier = iBdMaterialService.getAllSuppiler();
        return AjaxResult.success(supplier);
    }
}
